package com.lmt_28;

import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class TCPClient {
    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1",8888);

        OutputStream os= socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);
        Scanner sc = new Scanner(System.in);
        new ClientReader(socket).start();
        while (true)
        {
            System.out.println("请输入：");
            String data = sc.nextLine();
            dos.writeUTF(data);
            dos.flush();
            if (data.equals("exit")){
                dos.close();
                socket.close();
                break;
            }
        }
    }
}
